﻿using Dorm.Maps;

namespace Dorm.Testes
{
    public class UserMap : EntityMap<Person>
    {
        public UserMap()
        {
            Map(x => x.Name);
            References(x => x.Type);
            HasManyToMany(x => x.Profiles).Cascade();
            HasMany(x => x.Permissions).Cascade();
            HasComponent(x => x.HomeAddress);
        }
    }

    public class AddressMap : ComponentMap<Address>
    {
        public AddressMap()
        {
            Map(x => x.Street);
            Map(x => x.Number);
            Map(x => x.City);
        }
    }

    public class ProfileMap : EntityMap<Profile>
    {
        public ProfileMap()
        {
            Map(x => x.Name);
            HasManyToMany(x => x.Users).Cascade();
            HasMany(x => x.Permissions).Cascade();
        }
    }

    public class PermissionMap : EntityMap<Permission>
    {
        public PermissionMap()
        {
            References(x => x.Profile);
            References(x => x.SystemUser);
            Map(x => x.ScreenName);
        }
    }

    public class UserTypeMap : EntityMap<UserType>
    {
        public UserTypeMap()
        {
            Map(x => x.Name);
        }
    }

}
